package cn.edu.scau.cmi.yangzhichao.singleton;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.stage.Stage;


public class ChairManViewController {
    private ObservableList<ChairMan> chairMen= FXCollections.observableArrayList();
    private Stage dialogStage;
    @FXML
    private TableView<ChairMan> ChairMantable;
    @FXML
    private TableColumn<ChairMan, String> ChairMancolumn;
    @FXML
    private TextField textField;
    @FXML
    private void initialize(){
        chairMen.add(ChairMan.getInstance("毛泽东"));
        ChairMantable.setItems(chairMen);
        ChairMancolumn.setCellValueFactory(cellData->cellData.getValue().nameProperty());
    }
    public void setDialogStage(Stage dialogStage) {
        this.dialogStage = dialogStage;
    }
    @FXML
    private void handleSubmit(){
        if(textField.getText().toString().equals("")){
            Alert error = new Alert(Alert.AlertType.ERROR,"ERROR:输入为空");
            Button err = new Button();
            err.setOnAction((ActionEvent)->{

            });
            error.show();
        }else{
            ChairMan Chairman=ChairMan.getInstance(textField.getText().toString());
            chairMen.add(Chairman);
        }

    }
}
